package cn.yusei.teamTribe.service.search;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.yusei.teamTribe.dao.post.PostDAO;
import cn.yusei.teamTribe.dao.post.PostTagDAO;
import cn.yusei.teamTribe.dao.user.UserDAO;
import cn.yusei.teamTribe.dao.user.po.UserPO;

@Service
public class SearchService {

	@Autowired
	private UserDAO userDAO;
	@Autowired
	private PostTagDAO postTagDAO;
	@Autowired
	private PostDAO postDAO;
	
	public int[] getIdByTeam(int teamId){
		int[] ids = postDAO.selectByTeamId(teamId);
		return ids;
	}
	
	public int[] getIdsByTag(int tagId){
		int[] ids = postTagDAO.selectPostById(tagId);
		return ids;
	}
	
	public Integer getIdByEmail(String email){
		UserPO userPO = userDAO.selectByEmail(email);
		if(userPO != null){
			return userPO.getId();
		}
		return null;
	}
	
	public Integer getIdByPhone(String phone){
		UserPO userPO = userDAO.selectByPhone(phone);
		if(userPO != null){
			return userPO.getId();
		}
		return null;
	}
	
	public java.util.List<Integer> getIdsByName(String name){
		java.util.List<Integer> ids = userDAO.selectIdByName(name);
		return ids;
	}
	

}
